<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/**
			 * @param {number} n
			 * @return {number}
			 */
			var numberOfMatches = function(n) {
				let num = 0
				const recur = (n) => {
					// debugger
					if(n == 1){
						return num;
					}
					if(n % 2 == 0){
						n = n/2
						num += n
					}else{
						n = (n-1)/2
						num += (n+1)
					}
					return recur(n)
				}
				return recur(n)
			};
			console.log(numberOfMatches(7));
		</script>
	</body>
</html>
